import gc
import time
import random

reg = 1000*1000
duration = 3
candidates = [0,1]
size_range = lambda: random.randint(reg*2,reg*100)
for _ in range(10):
    size = size_range()
    print("allocating:",size)
    mlist = [1]
    mlist = mlist*size
    print("memory allocated!",size)
    time.sleep(duration)
    del mlist
    gc.collect()
